<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<%@ include file="../include/head.jsp" %>
	<meta charset="UTF-8">
	<title>crm</title>
</head>

<body class="crm">

	<jsp:include page="../include/top.jsp">
		<jsp:param value="contact" name="tag"/>
	</jsp:include>

	<div class="container-fluid">
		<div class="row-fluid">
			<div class="span8">
				<div class="well screen">
					<div class="page-header header">
							上传CSV文件
					</div>
					<div class="live_search_spinner" behavior="spinner" id="parties_loading">
					  <div class="liner">
					    <h3>处理中...</h3>
					    <img src="new_files/indicator.gif" alt="WorkXP">
					  </div>
					</div>
					<div class="main" id="main">
						<form accept-charset="UTF-8" action="upload.action" class="simple_form new_contact_import" enctype="multipart/form-data" id="import_form" method="post" novalidate="novalidate">
						<div style="margin:0;padding:0;display:inline">
						<input name="utf8" value="✓" type="hidden"><input name="authenticity_token" value="tH6k6f0ok5Lz5kS91LG6jbMpDy3UYrRyDAYrTbt+iLY=" type="hidden"></div>
							<input id="contact_import_src" name="fileType" value="csv" type="hidden">
	
							<div class="control-group string optional"><label class="string optional control-label" for="contact_import_user"> 请选择要导入的CSV格式的文件，建议使用UTF-8编码（将编辑好的csv文件用记事本打开，另存为时选择文件编码为UTF-8）</label>
							<div class="controls">
							<input id="file" name="file" required="required" size="30" type="file">
							</div>
							<div>
								<span id="warn" style="color:red;"></span>
								<c:if test="${param.code == 10011 }">
									<span style="color:red;">文件内容有错，请检查！</span>
								</c:if>
							</div>
							
							</div>		
							<div class="form-actions">
								<input id="btn" class="btn btn-primary" data-loading-text="处理中.." name="commit" value="上传导入" type="button">
								<a href="#" class="btn">取消</a>
							</div>
						</form>
					</div>
				</div>	

			</div>
		</div>
	</div>
	
	<script type="text/javascript">
		$(document).ready(function() {
			$("#btn").click(function(){
				var v = $("#file").val();
				if(v == "") {
					$("#warn").html("请选择要上传的文件！");
				} else {
					alert(v);
					var a = val(v);
					if(a) {
						$("#import_form").submit();
					} else {
						$("#warn").html("请选择CSV文件！");
					}
				}
			});
		});

		function val(email) {
		var patten = new RegExp(/[a-zA-Z]:\\[^\:\*\?\/\|\"\<\>]+\.csv/);
		return patten.test(email);
	}
	</script>
	
</body>
</html>

